﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using NewDDSys.Entity;
using NewDDSys.IBLL;
using NewDDSys.IDAL;
using NewDDSys.Factory;
using NewDDSys.Utility;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class Web_ZKCDT : System.Web.UI.Page
{
    private string num = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        btnOK.Attributes.Add("onclick", "javascript:if(confirm('" + "确认无误，并提交么？" + "')== false) return false;");
    }
    protected void btnPGCX_Click(object sender, EventArgs e)
    {
        Response.Redirect(string.Format("PGCX.aspx?Pinzhong={0}", "中板"));
        txtPinzhong.Text = Request.QueryString["Pinzhong"];
        txtPinzhong.Attributes["contentEditable"] = "false";
        txtGuige.Text = Request.QueryString["Guige"];
        txtGuige.Attributes["contentEditable"] = "false";
        num = Request.QueryString["Num"];
    }
    protected void btnOK_Click(object sender, EventArgs e)
    {
        int checkValue = 0;
        ZkcdtInfo zb = new ZkcdtInfo();
        zb.Num = num;
        zb.Banzu = Session["用户信息.班组"].ToString();
        zb.Tianbao = Session["用户信息.姓名"].ToString();
        zb.Kday = DateTime.Now.ToString();
        zb.Dtnum = "ZB" + zb.Kday;
        checkValue = BLLFactory.CreateZkcdtBLL().Add(zb);
        if (checkValue >= 1)
        {
            Response.Write(" <script   language=javascript> window.alert( ' 提交成功！ ');</script> ");
        }
        if (txtKN.Text.ToString() != "")
        {
            decimal kn = Convert.ToDecimal(txtKN.Text.ToString());
            decimal kndc = Convert.ToDecimal(txtKNDC.Text.ToString());
            decimal knkl = Convert.ToDecimal(txtKNKL.Text.ToString());
            decimal knzy = Convert.ToDecimal(txtKNZY.Text.ToString());
            decimal knwj = Convert.ToDecimal(txtKNWJ.Text.ToString());
            if (kn < (knwj + kndc + knkl + knzy))
                Response.Write(" <script   language=javascript> window.alert( ' 库内、库内短尺、库内可利用、库内自用材、库内未缴库数量不正确！ ');</script> ");
            else
            {
                BLLFactory.CreateZkcdtBLL().UpdateKN(zb.Dtnum, kn);
                BLLFactory.CreateZkcdtBLL().UpdateKNDC(zb.Dtnum, kndc);
                BLLFactory.CreateZkcdtBLL().UpdateKNKL(zb.Dtnum, knkl);
                BLLFactory.CreateZkcdtBLL().UpdateKNZY(zb.Dtnum, knzy);
                BLLFactory.CreateZkcdtBLL().UpdateKNWJ(zb.Dtnum, knwj);
            }
        }
        if (txtDK.Text.ToString() != "")
        {
            decimal dk = Convert.ToDecimal(txtDK.Text.ToString());
            decimal dkdc = Convert.ToDecimal(txtDKDC.Text.ToString());
            decimal dkkl = Convert.ToDecimal(txtDKKL.Text.ToString());
            decimal dkzy = Convert.ToDecimal(txtDKZY.Text.ToString());
            decimal dkwj = Convert.ToDecimal(txtDKWJ.Text.ToString());
            if (dk < (dkwj + dkdc + dkkl + dkzy))
                Response.Write(" <script   language=javascript> window.alert( ' 东库、东库短尺、东库可利用、东库自用材、东库未缴库数量不正确！ ');</script> ");
            else
            {
                BLLFactory.CreateZkcdtBLL().UpdateDK(zb.Dtnum, dk);
                BLLFactory.CreateZkcdtBLL().UpdateDKDC(zb.Dtnum, dkdc);
                BLLFactory.CreateZkcdtBLL().UpdateDKKL(zb.Dtnum, dkkl);
                BLLFactory.CreateZkcdtBLL().UpdateDKZY(zb.Dtnum, dkzy);
                BLLFactory.CreateZkcdtBLL().UpdateDKWJ(zb.Dtnum, dkwj);
            }
        }
        Response.Redirect("ZKCDTJL.aspx");
    }
    protected void btnRepeat_Click(object sender, EventArgs e)
    {
        txtKN.Text = "";
        txtKNDC.Text = "";
        txtKNKL.Text = "";
        txtKNZY.Text = "";
        txtKNWJ.Text = "";
        txtDK.Text = "";
        txtDKDC.Text = "";
        txtDKKL.Text = "";
        txtDKZY.Text = "";
        txtDKWJ.Text = "";
    }
}
